﻿using M.ShopMachine.Domain;
using M.ShopMachine.Domain.Dto;
using M.ShopMachine.Read.WebApi.Application.Command.DeviceCommand;
using M.ShopMachine.Repository.Interface;
using MediatR;

namespace M.ShopMachine.Read.WebApi.Application.Handler.DeviceHandler
{
    public class GetTableDeviceHandler : IRequestHandler<GetTableDeviceCommand, List<Device>>
    {
        private readonly IDeviceRepository deviceRepository;

        public GetTableDeviceHandler(IDeviceRepository deviceRepository)
        {
            this.deviceRepository = deviceRepository;
        }

        public async Task<List<Device>> Handle(GetTableDeviceCommand request, CancellationToken cancellationToken)
        {
            return await deviceRepository.GetTableDeviceAsync(request.Number, request.Name, request.State);
        }
    }
}
